//
//  OnlineExamViewController.m
//  jinnengExam
//
//  Created by mac on 2020/11/13.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "EOnlineTrainDescriptionViewController.h"

#import "OnlineExamResultListViewController.h"

@interface EOnlineTrainDescriptionViewController ()
@property(nonatomic,strong) JznWebView *jznWebView;
@property(nonatomic) int page;
@end

@implementation EOnlineTrainDescriptionViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBarController.tabBar.frame = CGRectMake(0, 0, 0, 0);
    self.tabBarController.tabBar.hidden = YES;
    [self initView];
}

-(void) initView{
    [self.view addSubview:self.jznWebView];
    [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        if (@available(iOS 11.0, *)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.top.bottom.equalTo(self.view);
        }
    }];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.jznWebView loadLocalFile:@"/ios_jinneng/onlineTrainDescription" type:@"html"];
    [self registJSFunction];
}

-(void) registJSFunction{
    
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
    //NSString *trainDetail = [NSString stringWithFormat:@"getExamTrain(%@)",[self.examTrain mj_JSONString]];
    NSString *url = [NSString stringWithFormat:@"%@/professionalClass/findClassExamInfo" ,[URLUtil hostName]];
    NSDictionary *params = @{@"userId":[NSString stringWithFormat:@"%ld",self.loginDto.userId],@"professionalClassId":[[self.examTrain mj_JSONObject] objectForKey:@"professionalClassId"]};
    [JZNRequestUtil requestUrl:url requestParams:params success:^(DataResult *dataResult) {
        if(dataResult.code == 0){
            DataResult *examInfo = dataResult.data;
            
            NSString *url2 = [NSString stringWithFormat:@"%@/classCourse/findOnlineCourseList" ,[URLUtil hostName]];
            NSDictionary *params2 = @{@"userId":[NSString stringWithFormat:@"%ld",self.loginDto.userId],@"professionalClassId":[[self.examTrain mj_JSONObject] objectForKey:@"professionalClassId"]};
            [JZNRequestUtil requestUrl:url2 requestParams:params2 success:^(DataResult *dataResult2) {
                if(dataResult2.code == 0){
                    NSArray *array = dataResult2.data;
                    NSString *clear = [NSString stringWithFormat:@"getExamTrain(%@,%@,%@)",[examInfo mj_JSONString],[self.examTrain mj_JSONString],[array mj_JSONString]];
                    [self.jznWebView evaluateJavaScript:clear completionHandler:^(id _Nullable data, NSError * _Nullable error) {
                        
                    }];
                }else {
                }
            } failure:^(NSError *error) {
                
            }];
            
            
           
        }else {
        }
    } failure:^(NSError *error) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
